<template>
	<view class="">
		<u-navbar :border-bottom="false" title-color="#333" title-bold title="我的知识分享" title-size="36"></u-navbar>
		<view class="tab-div">
			<view class="zhishi">
				<view class="flex flex_end ">
					<view class="gl-btn" @click="delshow=!delshow">
						<u-icon name="list-dot" color="#666" size="28"></u-icon>
						管理
					</view>
				</view>
				
				<view class="zs-item flex flex_sb" v-for="(item2,index2) in anliList" :key="index2" @click="todetail(2,item2)">
					<view class="">
						<view class="line_1 font_weight">
							{{item2.title}}
						</view>
						<view class="u-m-t-16 line_3 font_14_666 linhe48">
							<rich-text :nodes="item2.description"></rich-text>
						</view>
					</view>
					<view class="del-icon u-m-l-10" v-if="delshow">
						<image @click.stop="del(item2)" class="del-icon" src="../../../../static/img/home/del-icon.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="" style="width: 100%;height: 170rpx;"></view>
		<view class="btn-bo">
			<button class="btn_login_btn" @click="add">
				添加
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				delshow:false,
				anliList:[],
				total:0,
				pageNum:1,
				pageSize:20,
			}
		},
		onReachBottom() {
			if (this.pageNum * this.pageSize > this.total) {
				// uni.hideNavigationBarLoading();
			} else {
				this.pageNum++;
				this.getanli()
			}
		},
		onShow() {
			this.pageNum = 1
			this.getanli()
		},
		methods: {
			getanli(){
				this.$api({
					url: '/lawyer/my_getKnowledgeList',
					method: 'get',
					data: {
						page:this.pageNum,
						limit:this.pageSize,
						token:uni.getStorageSync("token"),
						lawyer_id:0 //律师ID，所有数据传-1，自己数据传0，其它律师数据传具体ID
					},
				}).then(res => {
					if (res.code == 1) {
						// this.anliList = res.data.list
						this.total=res.data.count
						let data = res.data.list
						if (this.pageNum == 1) {
							this.anliList = data
						} else {
							this.anliList = [...this.anliList, ...data]
						}
					} 
				})
			},
			del(e){
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认删除吗',
					success: function(res) {
						if (res.confirm) {
							that.$api({
								url: '/lawyer/delKnowledgeInfo',
								method: 'post',
								data: {
									token:uni.getStorageSync("token"),
									ids:e.id
								},
							}).then(res => {
								if (res.code == 1) {
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									})
									that.getanli()
								} 
							})
						}
					}
				});
			},
			todetail(e,item) {
				uni.navigateTo({
					url: "/pages/lawyer/anliDetail?type=" + e+"&id="+item.id
				})
			},
			add(){
				uni.navigateTo({
					url: "/subPackageA/pages/lawyerVersion/mine/addzhishi"
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.linhe48 {
		line-height: 40rpx;
	}
	.del-icon{
		width: 40rpx;
		height: 40rpx;
	}
	.btn-bo{
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0,0,0,0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 9;
		
		.btn_login_btn{
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #fff;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
			font-weight: bold;
		}
	}
	.gl-btn{
		width: 130rpx;
		height: 48rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		border: 2rpx solid #605F6A;
		text-align: center;
		line-height: 48rpx;
	}
	.tab-div {
		width: 750rpx;
		// height: 672rpx;
		padding: 32rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0 auto;
	}

	.zs-item {
		padding: 32rpx 0;
		border-bottom: 2rpx solid #EFEFEF;
	}
</style>